/*
function getLatest() {
    
    $.get('budget?action=getLatest', function(latest) {
        
        shrinkMenu();
        loadContent(latest);
        
    });
       
}
*/

function getLatestTransactions() {
    
    $.ajax({
        type: "GET",
	url: "resources/xml/transactions.xml",
	dataType: "xml",
	success: function(xml) {
 
            var data = "";
            var id;
            var date;
            var title;
            var bank;
            var tags;
            
 
            $(xml).find('transaction').each(function() {
               
               id       = $(this).find("id").text();
               date     = $(this).find("date").text();
               title    = $(this).find("title").text();
               bank     = $(this).find("bank").text();
               tags     = "Mat";
                
               data += "<tr><td>" + date + "</td><td>" + title + "</td><td>" + tags + "</td><td>" + bank + "</td></tr>\n";
                
            });    
 
            shrinkMenu();
            loadContent("#latest_transactions", data);

	}
    });
}

function getLatestTags() {
    
    $.ajax({
        type: "GET",
	url: "resources/xml/tags.xml",
	dataType: "xml",
	success: function(xml) {
 
            var data = "";
            var id;
            var name;
           
            
 
            $(xml).find('tag').each(function() {
               
               id       = $(this).find("id").text();
               name     = $(this).find("name").text();
                
               data += "<li id='" + id + "'>" + name + "</li>\n";
                
            });    
 
            
            loadContent("#latest_tags", data);

	}
    });
}


function saveTransaction() {
    
    data = $('#form_add_transaction').serialize();
    
    
    $.ajax({
        type: "POST",
	url: "budget?action=addTransaction",
        data: data,
	success: function(res) {
 
            if(eval(res.toString(), "true")) {
                hidePopup();
                getLatestTransactions();
            }
            else {
                showFormError(res);
            }

	}
    });
    
    
    
    return false;
}


function getCategories() {
    
    $.get('budget?action=getCategories', function(latest) {
        
        shrinkMenu();
        loadContent(latest);
        
    });
       
}


function getPopup() {
    
    $.get('resources/snippets/settings.xhtml', function(latest) {
      
        $('')
      
    });
    
    
}
